<?php
include_once WEB_ROOT."/Public/Set/Email.php";
class M_Email{
  static public function send($to, $subject, $message)
  {
    $mail = new M_PHPMailer();
    $mail->IsSMTP();                 // 启用SMTP
    $mail->Host = SMTP_HOST;           //SMTP服务器
    $mail->SMTPAuth = true;                  //开启SMTP认证
    $mail->Username = SMTP_USER;            // SMTP用户名
    $mail->Password = SMTP_PASS;                // SMTP密码
    $mail->From = FROM;            //发件人地址
    $mail->IsHTML(true);                 // 是否HTML格式邮件
    $mail->CharSet = 'utf-8';
    $mail->Encoding = 'base64';
    $mail->WordWrap = 50;                    //设置每行字符长度

    $mail->FromName = "[".FIRST_TITLE."]";              //发件人
    $mail->AddAddress($to);
    $mail->AddReplyTo(FROM, "Information");    //回复地址
    $mail->Subject = $subject;          //邮件主题
    $mail->Body    = $message;
    $mail->AltBody = "This is the body in plain text for non-HTML mail clients"; //邮件正文不支持HTML的备用显示
    if(!$mail->Send())
      {
	echo "无法发送邮件，我们需要您的帮助，请联系我们的管理员，谢谢。xiaopei0206@gmail.com <p>";
	echo "Mailer Error: " . $mail->ErrorInfo;
	exit;
      }
  }
}
